<template>
  <div v-if="pageflag" class="display-flex fd-row jc-space-around mt-20">
    <div
      v-for="(item, i) in lineData"
      :key="i"
      class="display-flex fd-column ai-center"
    >
      <el-progress
        type="circle"
        :width="140"
        :color="item.color"
        define-back-color="#1A3690"
        text-color="#fff"
        :stroke-width="18"
        :percentage="item.value"
      ></el-progress>
      <span class="mt-10">{{ item.name }}</span>
    </div>
    <!-- <div class="display-flex fd-column ai-center">
      <el-progress class="blue" type="circle" color="#4FDCFF" define-back-color="#1A3690" text-color="#fff" :stroke-width="18" :percentage="0"></el-progress>
      <span  class="mt-10">离线率</span>
    </div> -->
  </div>
  <Reacquire v-else @onclick="getData" style="line-height: 200px">
    重新获取
  </Reacquire>
</template>

<script>
export default {
  data() {
    return {
      pageflag: true,
      lineData: [],
    };
  },
  created() {
    this.getData();
  },
  mounted() {},
  beforeDestroy() {},
  methods: {
    getData() {
      let res = {
        0: 100,
        1: 0,
      };
      this.pageflag = true;
      this.lineData = [];
      const colorArr = ["#9E48FF", "#4FDCFF"];
      for (const i in res) {
        const name = i === "0" ? "离线率" : "在线率";
        const obj = {
          name: name,
          value: res[i],
          color: colorArr[i],
        };
        this.lineData.push(obj);
      }
      this.pageflag = true;
    },
  },
};
</script>
<style lang="scss" scoped></style>
